package com.framework.modules.base.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.framework.modules.base.entity.TokenEntity;
import com.framework.modules.base.entity.UserEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

/**
 * 用户
 */
public interface UserDao extends BaseMapper<UserEntity> {

    UserEntity queryByUsernameOrMobile(String username);

    Integer insertAndGetUserId(UserEntity entity);

    @Insert("insert into tb_user_info(uid,`level`) values(#{uid},#{level})")
    Integer newUserInfo(@Param("uid") Long uid,@Param("level") Integer level);

    @Insert("insert into tb_user_balance(uid,coin,balance,total_amount,adddate) values(#{uid},0,#{balance},#{total_amount},#{adddate})")
    Integer newUserBalance(@Param("uid") Long uid,@Param("balance") BigDecimal balance,@Param("total_amount") BigDecimal total_amount,@Param("adddate") Integer adddate);

    @Insert("INSERT INTO tb_token (user_id,token, expire_time, update_time) VALUES (#{userId},#{token},#{expireTime},#{updateTime})")
    Integer newUserToken(TokenEntity token);

}
